<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        var evalRPN = function (tokens) {
            let stack = []
            let m = tokens.length
            let i = 0
            let result = 0
            let right = 0
            let left = 0
            while (i < m) {
                if (!isNaN(parseInt(tokens[i]))) {
                    stack.push(parseInt(tokens[i++]))
                } else {
                    switch (tokens[i]) {
                        case '+':
                            right = stack.pop()
                            left = stack.pop()
                            result = left + right
                            stack.push(result)
                            i++
                            break
                        case '-':
                            right = stack.pop()
                            left = stack.pop()
                            result = left - right
                            stack.push(result)
                            i++
                            break
                        case '*':
                            right = stack.pop()
                            left = stack.pop()
                            result = left * right
                            stack.push(result)
                            i++
                            break
                        case '/':
                            right = stack.pop()
                            left = stack.pop()
                            result = left / right|0
                            stack.push(result)
                            i++
                            break
                    }
                }
            }
            return stack[0]
        };
        // console.log(6/-132)
        // console.log(Math.floor(6/-132))
        // console.log(Math.ceil(6/-132))
        // console.log(13/5)
        // console.log(Math.floor(13/5))
        // console.log(Math.ceil(13/5))
        console.log(evalRPN(["10","6","9","3","+","-11","*","/","*","17","+","5","+"]))
    </script>
</body>

</html>